use std::cmp::Ordering::{Greater, Less, Equal};
struct Solution {}
impl Solution {
  pub fn find_min_difference(time_points: Vec<String>) -> i32 {
      if time_points.len() > 1440 {
          return 0;
      }
      let judge = |a: &Vec<&str>, b: &Vec<&str>| {
        if let dh = i32::from_str_radix(a[0], 10).unwrap() - i32::from_str_radix(b[0], 10).unwrap() {
          if dh > 0 {
            return Greater;
          } else if dh < 0 {
            return Less;
          }
        }
        if let dm = i32::from_str_radix(a[1], 10).unwrap() - i32::from_str_radix(b[1], 10).unwrap() {
          if dm > 0 {
            return Greater;
          } else if dm < 0 {
            return Less;
          } else {
            return Equal
          }
        }
        Equal
      };
      let calc = |a: &Vec<&str>, b: &Vec<&str>| {
        (i32::from_str_radix(a[0], 10).unwrap() - i32::from_str_radix(b[0], 10).unwrap()) * 60 + i32::from_str_radix(a[1], 10).unwrap() - i32::from_str_radix(b[1], 10).unwrap()
      };
      let mut time: Vec<Vec<_>> = time_points.iter().map(|t| {
        t.split(':').collect()
      }).collect();
      time.sort_by(|a, b| judge(a, b));
      let h = (i32::from_str_radix(time[0][0], 10).unwrap() + 24).to_string();
      time.push([&h, time[0][1]].to_vec());
      let mut ret = 1440;
      time.windows(2).for_each(|a| {
        let d = calc(&a[1], &a[0]);
        if ret > d {
          ret = d;
        }
      });
      ret
  }
}